window.onload=function(){


$("#sousuobox").focus(function(){
    $("#sousuobox").css("left","0px")
    $("#sousuobtn").css("left","0px")
    $("#sousuoback").css("display","block")
    $(".divbg").css("display","none");
     $(".titleimg").css("display","none");
     $("#indexBox").css("background","#f1f1f1");
     $(".icon_box_cen_nav li").css("display","none");
    $("#topBox").css("position","fixed");
      $("#e_queryBox").css("display","block");
      $("#topBox").animate({
            top:'0px',
            left:'0px',
            opacity:'1',
            height:'55px',
            width:'100%',
            background:'#f00',
            margin:'0px',
            paddingTop:'5px'

            
         
          },300);
    
    $("#e_queryBox").animate({
            top:'60px',
            left:'0px',
            opacity:'1',
            height:'100%',
            width:'100%',
            margin:'0px',
            padding:'0px',
            display:'block' 
          },300);

})
$("#sousuoback").click(function(){
  
    $("#e_queryBox").css("position","fixed");
       $("#sousuobox").css("left","-10px")
    $("#sousuobtn").css("left","-10px")
     $("#sousuoback").css("display","none")
      $(".icon_box_cen_nav").css("background","#fff");
     $(".divbg").css("display","block");
     $(".titleimg").css("display","block");
     $("#indexBox").css("background","#4f77aa");
     $(".icon_box_cen_nav li").css("display","block");
    
    $("#e_queryBox").animate({
            top:'100%',
            opacity:'1',
            height:'100%',
            width:'100%'
          },300);
     
  $("#topBox").css({"position":"relative","width":"100%","margin-top":"0px","padding-top":"0px;"});
});
$("#sousuobtn").click(function(){
    if ($("#sousuobox").val()==''){
        alert("请输入关键字查询或者点击新增按钮")
    }

});

};//windows 结尾

$(function () {
    $('#eq_null').css("display", "none");
})


function search() {
    $('#equery_content').empty();
    var contents = $("#sousuobox").val();
    var msg = "&name=" + contents;
    $.ajax({
        url: "/a/ajz/ajzBaseinfo/search",
        type: "POST",
        data: msg,
        dataType: "json",
        async: true,
        success: function (result) {
            searchResult(result)
        }
    })
}

//判断查询框输入的值
function searchResult(result){
    // alert(JSON.stringify(result))
    if (jQuery.isEmptyObject(result)) {//判断json值是否为空
        $("#equery_content").css("display", "none");
        $("#eq_null").css("display", "block");
    } else {
        $("#equery_content").css("display", "block");
        $("#eq_null").css("display", "none");
        $.each(result,function(key,value){
            var num = key.indexOf("|");
            var id = key.substring(0,num);
            var name = key.substring(num+1);
            $("#equery_content").append("<i id=" + id + ">" + name + "<img style='height:5%;width: 5%;float:right;margin: 1.7% 5% 0% 0%;' src='/static/ajz/mobile/img/"+value+".png' ></i>");
        })
    }
}

$("#equery_content").on("click", "i", function () {//动态添加元素时给新节点动态生成方法
    var storeName = $(this).text();
    var id = this.id;
    $('#sousuobox').val(storeName);
    var msg = "name=" + storeName + "&id=" + id;
    //点击完下拉列表后跳转
    location.href = "/a/ajz/ajzBaseinfo/searchName?" + msg;
});